package com.damocode.starter.yx.http;

import com.alibaba.fastjson.JSONObject;
import org.springframework.util.StringUtils;

public class YxMsgRequest extends YxRequest {

    public YxMsgRequest(String url,String appKey,String appSecret){
        super(url,appKey,appSecret);
    }

    public void setFrom(String from) {
        if(!StringUtils.isEmpty(from)){
            this.putParameter("from",from);
        }
    }

    public void setOpe(String ope) {
        if(!StringUtils.isEmpty(ope)){
            this.putParameter("ope",ope);
        }
    }

    public void setTo(String to) {
        if(!StringUtils.isEmpty(to)){
            this.putParameter("to",to);
        }
    }

    public void setType(String type) {
        if(!StringUtils.isEmpty(type)){
            this.putParameter("type",type);
        }
    }


    public void setFromAccid(String fromAccid) {
        if(!StringUtils.isEmpty(fromAccid)){
            this.putParameter("fromAccid",fromAccid);
        }
    }

    public void setToAccids(String toAccids) {
        if(!StringUtils.isEmpty(toAccids)){
            this.putParameter("toAccids",toAccids);
        }
    }

    public void setMessage(String message) {
        if(!StringUtils.isEmpty(message)){
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("msg",message);
            this.putParameter("body",jsonObject.toJSONString());
        }
    }

    public void setBody(String body){
        if(!StringUtils.isEmpty(body)){
            this.putParameter("body",body);
        }
    }

    public void setMsgtype(int msgtype){
        this.putParameter("msgtype",msgtype);
    }

    public void setAttach(String attach) {
        if(!StringUtils.isEmpty(attach)){
            this.putParameter("attach",attach);
        }
    }
}
